﻿using System;
using System.Net;
using System.Net.Mail;
using MyHealthByDesign.Properties;

namespace MyHealthByDesign.Helper
{
    public class Mail
    {
        public void SendEmailAddress(string emailAddress, string password)
        {
            try
            {
                var message = new MailMessage(Settings.Default.MailFrom, emailAddress)
                                              {
                                                  Subject = Constants.FORGOTTON_SUBJECT,
                                                  Body = "You have requested us to email your password. Here is your password: " + password,
                                                  IsBodyHtml = true
                                              };
                
                var client = new SmtpClient(Constants.SMTP_SERVER, Constants.SMTP_PORT)
                                 {
                                     Credentials = new NetworkCredential(Constants.SMTP_USERNAME, Constants.SMTP_PASSWORD),
                                     EnableSsl = true
                                 };
                client.Send(message);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
    }
}